<template>
  <!--扫码后的页面-->
  <div>
    <p class="imgid">
      <img :src="accountGoods.coverImg | imgPathFilter" alt="" width="100%">
      <span>NO.{{accountGoods.vipCardNo}}</span>
    </p>
    <div class="tip">
      <p>请让会员出示身份证件并认真 </p>
      <p>核对以下信息确保与证件一致</p>
    </div>
    <wv-group class="mymsg">
      <wv-cell title="姓名" :value="accountGoods.userName"></wv-cell>
      <wv-cell title="证件号" :value="accountGoods.identityNo"></wv-cell>
    <!--  <wv-cell title="卡有效期" :value="showDate"></wv-cell>
      <wv-cell title="会员状态" value="有效" v-if="accountGoods.vipCardState==1"></wv-cell>-->
      <wv-cell title="贵宾厅服务状态" value="未过期" v-if="!accountGoods.vipServerIsExpre"></wv-cell>
      <wv-cell title="贵宾厅服务状态" value="已过期" v-if="accountGoods.vipServerIsExpre"></wv-cell>
      <wv-cell title="开卡地区" :value="accountGoods.airportName"></wv-cell>
    </wv-group>
    <p class="bottom">
      <span @click="goCheck(accountGoods,employeeType)">确定</span>
      <span @click="goCancel()">取消</span>
    </p>
    <div class="model" v-show="isExpireDate">
      <div class="bg"></div>
      <div class="modelContent buzu">
        <img src="../../../assets/close.png" alt="" width="15" @click="isExpireDate=false">
        对不起，该会员贵宾厅已过 有效期，不能再使用该服务，如想继续尊享贵宾厅服务，可告知会员续卡。
        <p class="btn">
          <button @click="isExpireDate=false">确定</button>
        </p>
      </div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import {getStore} from '../../../../test/unit/storage'
  import {getAccountGoodsInfo, accountGoodsCardUseCheck} from '../../../../test/unit/http'
  import {Toast} from 'we-vue'
  export default {
    name: 'yanzheng',
    props: {},
    data() {
      return {
        accountGoods: {},
        isExpireDate: false
      };
    },
    methods: {
      getData(params){
        getAccountGoodsInfo(params).then(res => {
          console.log(res);
          if (res.code === 100) {
            this.accountGoods = res.object;
          } else {
            Toast.fail(res.info);
          }
        })
      },
      goAccountGoodsCardUseCheck(params){
        accountGoodsCardUseCheck(params).then(res => {
          let employeeType = params.employeeType;
          if (res.code === 100) {
            if (employeeType == 'platform' || employeeType == 'third') {
              this.$router.push({path: 'choose', query: {accountGoodsId: params.accountGoodsId}})
            }
            if (employeeType == 'shop') {
              this.$router.push({path: 'yinpin', query: {accountGoodsId: params.accountGoodsId}})
            }
          } else {
            Toast.fail(res.info);
          }
        })
      },
      goCancel(){
        this.$router.go(-1)
      },
      goCheck(accountGoods, employeeType){
        this.goAccountGoodsCardUseCheck({accountGoodsId: accountGoods.accountGoodsId, employeeType: employeeType});
      }
    },
    created() {
      let employeeType = getStore('employeeType');
      this.employeeType = employeeType;
      let accountGoodsId = this.$route.query.accountGoodsId;
      let params = {accountGoodsId: accountGoodsId};
      this.getData(params);
    },
    computed: {
      showDate: function () {
        let accountGoods = this.accountGoods;
        return accountGoods.buyDate + '——' + accountGoods.expireDate;
      }
    },
    components: {}
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less" rel="stylesheet/less">
  .imgid{
    position: relative;
    span{
      position: absolute;
      top: 20px;
      right: 28px;
      color: #7b4813;
      font-weight: 700;
    }
  }
  .mymsg{
    padding-bottom: 60px;
  }
  .bg{
    background-color: rgba(0,0,0,0.3);
    width: 100%;
    height: 100%;
    position: fixed;
    top:0;
    left: 0;
    bottom: 50px;
  }
  .model .modelContent{
    background-color: #fff;
    border-radius: 8px;
    position: fixed;
    left: 50%;
    top:50%;
    margin-left: -43%;
    margin-top:-111px;
    z-index: 2;
    padding: 40px 10px 20px;
    width: 80%;
    text-align: left;
    img{
      position: absolute;
      right: 10px;
      top:10px
    }
    .btn{
      button{
        height: 42px;
        line-height: 42px;
        color: #fff;
        outline: none;
        border:none;
        width: 100%;
        border-radius: 8px;
        margin-top: 25px;
        background-color: #f98e3c;
      }
    }
  }
  .banner{
    padding-top: 10px;
  }
  .tip{
    background-color: #f84743;
    color: #fff;
    padding: 10px;
  }
  .bottom{
    z-index: 999;
    position: fixed;
    bottom: 0;
    height: 50px;
    line-height: 50px;
    display: flex;
    width: 100%;
    font-size: 17px;
    background-color: #fff;
    span{
      flex: 1;
      width: 50%;
      display: inline-block;
    }
    :first-child{
      color: #fff;
      background-color: #f98e3c;
    }
    :last-child{
      color: #f88d3b;
    }

  }
</style>
